<template>
    <div>
    <div class="tabpage">
        
        <van-tabs color="#EE87B6"  v-model="active" @click="onClick">
            <van-tab title="最新问题"><Que :newprop="active==0?newarr:hotarr" v-on:childByValue="childByValue"></Que></van-tab>
            <van-tab title="最热问题"><Que :newprop="active==1?hotarr:newarr" v-on:childByValue="childByValue"></Que></van-tab>
        </van-tabs>
    </div>
    <BottomBar></BottomBar>        
    </div>
</template>
<script>
import axios from "axios"
import Que from '../components/quan/question'
import BottomBar from '../components/bottombar.vue'
//import { Toast } from 'vant';
export default {
    components:{
        BottomBar,
        Que,
    },
    data() {
        return {
            pageIndex:0,
            pageSize:20,
            newarr:[],
            hotarr:[],
            active:0,
            clientId:0
        }
    },
    methods:{
        // 判断当前点击的是哪个标签
        onClick(title) {
            this.title=title
            window.console.log(this.title)//0  1
            },

        childByValue: function (childValue) {
        // childValue就是子组件传过来的值
        this.pageSize= childValue
        //window.console.log("逆传值"+this.pageSize)
      },
      get(){
        axios.get('https://api.hongbeibang.com/question/getHot?_t=1582698110603&csrfToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOjAsImV4cCI6MTc3MTU2NjMxNCwiaWF0IjoxNTgyMTc3NTE0fQ.iBmGtQ0fasTTaSuApywmN6Ms0aNYwUvkGLoXX6V6hO8', {
            params: {
               pageIndex:this.pageIndex,
               pageSize:this.pageSize
            },
            }).then(res => {
                this.newarr=res.data.data.content.data
               // window.console.log(this.newarr);
            });
        
             axios.get('https://api.hongbeibang.com/question/getNew?_t=1582696879216&csrfToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOjAsImV4cCI6MTc3MTU2NjMxNCwiaWF0IjoxNTgyMTc3NTE0fQ.iBmGtQ0fasTTaSuApywmN6Ms0aNYwUvkGLoXX6V6hO8', {
            params: {
               pageIndex:this.pageIndex,
               pageSize:this.pageSize
            },
            }).then(res => {
                this.hotarr=res.data.data.content.data
               // window.console.log(this.hotarr);
            })   
        },
    },
    created(){this.get()},
     activated(){  
        this.get()
    },
}
</script>
<style lang="stylus" scoped>

</style>